﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HotelResSystem2;
using System.Drawing;

namespace HotelResSystem2
{
    public class AvailRoomsProps : PropertyListener
    {
        RoomInventory rooms;

        public override void onCheckAvailEvent(object source, List<int> roomsList)
        {
            Form1 form = Form1.GetInstance();
            RoomList ListForm = RoomList.Instance();
            List<KeyValuePair<int, string>> roomsNumList = new List<KeyValuePair<int, string>>();
            foreach (int i in roomsList)
            {
                Room newroom = rooms.getRoom(i);
                KeyValuePair<int, string> kvp = 
                    new KeyValuePair<int, string>(newroom.RoomNum, newroom.ShortRoomDescription);
                roomsNumList.Add(kvp);
            }
            ListForm.SetRoomsData(roomsNumList);
            ListForm.ShowDialog();
            form.setRoomNumber(ListForm.SelectedRoom);
        }

        public override void initialize(RoomInventory roomInv)
        {
            roomInv.addRoomAvailListener(this);
            rooms = roomInv;
        }
    }
}
